package com.kc.sjwh.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kc.sjwh.dao.ResDao;
import com.kc.sjwh.dao.RoleDao;
import com.kc.sjwh.dao.UserDao;
import com.kc.sjwh.entity.po.Res;
import com.kc.sjwh.entity.po.Role;
import com.kc.sjwh.entity.po.User;
import com.kc.sjwh.other.QueryParam;

/**
 * 对外接口service
 * @author zhangguihua(hua7381@163.com)
 * date: 2017年8月14日
 */
@Service
public class InterfaceService {
	@Autowired
	ResDao resDao;
	@Autowired
	UserDao userDao;
	@Autowired
	RoleDao roleDao;

	public List<Res> getMenuList(String appCode, String userId) {
		return resDao.getMenus4User(appCode, userId);
	}

	public User getUserByAcc(String acc) {
		return userDao.getOne(new QueryParam().put("zh", acc));
	}

	public List<User> getUsersByIds(String ids) {
		if(ids==null) {
			return new ArrayList<User>();
		}
		String[] arr = ids.split(",");
		return userDao.getList(new QueryParam().addCondition("id", "in", arr));
	}

	public List<Role> getRolesByUserId(String userId, String appCode) {
		return roleDao.getListByAppAndUser(userId, appCode);
	}

}
